<!--
 * @Description: 
 * @Author: 胡涛
 * @Date: 2023-09-11 21:21:30
 * @LastEditors: 胡涛
 * @LastEditTime: 2024-07-19 23:43:01
-->
<template>
  <div class="page-wrapper">
    <div class="toolbar">
      <div class="breadcrumb">
        <a-breadcrumb>
          <a-breadcrumb-item>实时监测</a-breadcrumb-item>
          <a-breadcrumb-item>环境质量</a-breadcrumb-item>
          <a-breadcrumb-item>空气微站排口</a-breadcrumb-item>
        </a-breadcrumb>
      </div>
      <a-space>
        <a-button type="primary" @click="onHandleCreate" v-auth="'Create'">
          <template #icon>
            <PlusOutlined />
          </template>
          添加
        </a-button>
        <a-button type="primary" :loading="loading" @click="queryList">
          <template #icon>
            <SyncOutlined />
          </template>
          刷新
        </a-button>
        <!-- <a-button type="primary">
            <template #icon>
              <ExportOutlined />
            </template>
            导出
          </a-button> -->
      </a-space>
    </div>
    <div class="container">
      <div class="table">
        <a-table
          bordered
          sticky
          :columns="columns"
          :row-key="(record) => record.id"
          :data-source="dataSource"
          :pagination="pagination"
          :loading="loading"
          @change="handleTableChange"
        >
        </a-table>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import {
  PlusOutlined,
  ExportOutlined,
  SyncOutlined,
  EditOutlined,
  DeleteOutlined,
  SmileOutlined,
} from "@ant-design/icons-vue";
import { useListPage } from "@/helpers/pages";
import { h, onMounted, ref } from "vue";
import { PaginationConfig } from "ant-design-vue/es/pagination";
import api from "@/api";
import {
  Button,
  ButtonGroup,
  message,
  Popconfirm,
  Switch,
} from "ant-design-vue";
const {
  loading,
  dataSource,
  columns,
  pagination,
  popupModel,
  createQueryModel,
  onHandleCreate,
  onHandleUpdate,
} = useListPage<any, string>({
  columns: [
    {
      dataIndex: "enterName",
      title: "序号",
      customRender({ index }) {
        return index + 1;
      },
      align: "center",
      width: 50,
    },
    { dataIndex: "enterName", title: "企业名称", align: "center" },
    { dataIndex: "stationName", title: "排口名称", align: "center" },
    {
      dataIndex: "stationName",
      title: "排口状态",
      align: "center",
      customRender({ value }) {
        return value == 1 ? "正常" : "异常";
      },
    },
    {
      dataIndex: "stationName",
      title: "时间",
      align: "center",
      customRender() {
        return "--";
      },
    },
    {
      dataIndex: "a21026",
      align: "center",
      title: "二氧化硫(ug/m³)",
      customRender({ value }) {
        return value || "--";
      },
    },
    {
      dataIndex: "a21002",
      align: "center",
      title: "氮氧化物",
      customRender({ value }) {
        return value || "--";
      },
    },
    {
      dataIndex: "705",
      align: "center",
      title: "臭氧(ug/m³)",
      customRender({ value }) {
        return value || "--";
      },
    },
    {
      dataIndex: "a34002",
      align: "center",
      title: "PM10(ug/m³)",
      customRender({ value }) {
        return value || "--";
      },
    },
    {
      dataIndex: "a34004",
      align: "center",
      title: "PM2.5(ug/m³)",
      customRender({ value }) {
        return value || "--";
      },
    },
    {
      dataIndex: "a21004",
      align: "center",
      title: "二氧化氮(ug/m³)",
      customRender({ value }) {
        return value || "--";
      },
    },
  ],
});
const onDeleteItem = async (item: any) => {
  let callback = message.loading("数据操作中，请稍后");
  setTimeout(() => {
    callback();
    queryList();
  }, 1000);
};

const queryList = async () => {
  loading.value = true;
  let res = await api.get("/data/real-data/environ-quality.json");
  dataSource.value = res.items;
  pagination.total = res.totalCount;
  loading.value = false;
};

const handleTableChange = (pageConfig: PaginationConfig, filters: any) => {
  pagination.current = pageConfig.current;
  queryList();
};

onMounted(() => {
  queryList();
});
</script>

<style lang="less" scoped></style>
